/**
*
* Titre : CommandeRepository.java
* Description :
* Copyright : Copyright (c) 2013 JN Mauclair
* @author : JN MAUCLAIR
* @version : $Revision: $
*
* $Author$
* $Date$
*
*/
package fr.mauclair.domogeek.persist;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.repository.annotation.RestResource;

@RestResource(path = "commande", rel = "commande")
public interface CommandeRepository extends PagingAndSortingRepository<Commande, Long> {

//	@Override
//	@RestResource(exported = false)
//	void delete(Long id);
//
//	@Override
//	@RestResource(exported = false)
//	void delete(Commande entity);

	@Query("select c from Commande c where c.id in(:ids)")
	@RestResource(path = "id")
	Page<Commande> findById(@Param("ids") List<Long> ids, Pageable pageable);

//	@RestResource(path = "created")
//	List<Commande> findByCreatedGreaterThan(@Param("startDate") @ConvertWith(StringToISODateConverter.class) Date startDate);

	@Query("select count(c) from Commande c")
	@RestResource(path = "count")
	Long commandeCount();

	@RestResource(path = "name", rel = "names")
	public List<Commande> findByNameContains(@Param("name") String name);

}
